/*
 * AMatchResult.java
 *
 * Copyright(c) 2011
 * Michael Kroez
 * kroez@studiorutton.de
 *
 * All rights reserved.
 *
 * $Id$
 * 
 */

package de.studiorutton.tre;

public class AMatchResult {
	public int position = INFINITE_VALUE;
	public int end = INFINITE_VALUE;
	public int cost = INFINITE_VALUE;
	public int errors = INFINITE_VALUE;
	
	public static final int INFINITE_VALUE = Integer.MAX_VALUE;
	
	public AMatchResult() {
		
	}

	public boolean smallerThan(AMatchResult mr) {
		if (mr == null)
			return true;
		if (cost == mr.cost)
			if (position == INFINITE_VALUE)
				return false;
			else if (mr.position == INFINITE_VALUE)
				return true;
			else
				return position < mr.position;
		else
			return cost < mr.cost;
	}
	
	public String toString() {
		return "Position = " + position + " Errors = " + errors + " Cost = " + cost;
	}

}